package tests;

import org.junit.Assert;
import org.junit.Test;

import entities.ClassRoom;
import entities.Course;
import entities.TimeTableColumn;

public class Test_entities {
	/*
	 * test toString function in Course()
	 */
	@Test
	public void toString_Course() {
		String s;
		Course c = new Course("CS3201", 3, 300, "mark");
		s = c.toString();
		// Assert.assertEquals(s, "Course: " + "CS3201" + "	Room: " + "1234" +
		// "	" + "false" + "	" + "0900 - 1000" + "	" + "mark");
		Assert.assertEquals(s, "Course: CS3201	Room: null	ERROR	Duration : 3	ERROR - ERROR	mark");
	}
	/*
	@Test
	public void test_set_count() {
		Course c = new Course("CS3201", 3, 300, "mark");
		int count = c.set_count();
		this.count = c;
	}
	@Test
	public int test_get_count() {
		return this.count;
	}
	*/
	// Test checkTime() in Course()
	@Test
	public void test_checkTime1() {
		Course A = new Course();
		String result = A.checkStartTime(1) + A.checkEndTime(1);
		Assert.assertEquals(result, "0900 - 1000");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime2() {
		Course A = new Course();
		String result = A.checkStartTime(2) + A.checkEndTime(2);
		Assert.assertEquals(result, "1000 - 1100");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime3() {
		Course A = new Course();
		String result = A.checkStartTime(3) + A.checkEndTime(3);
		Assert.assertEquals(result, "1100 - 1200");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime4() {
		Course A = new Course();
		String result = A.checkStartTime(4) + A.checkEndTime(4);
		Assert.assertEquals(result, "1200 - 1300");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime5() {
		Course A = new Course();
		String result = A.checkStartTime(5) + A.checkEndTime(5);
		Assert.assertEquals(result, "1300 - 1400");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime6() {
		Course A = new Course();
		String result = A.checkStartTime(6) + A.checkEndTime(6);
		Assert.assertEquals(result, "1400 - 1500");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime7() {
		Course A = new Course();
		String result = A.checkStartTime(7) + A.checkEndTime(7);
		Assert.assertEquals(result, "1500 - 1600");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime8() {
		Course A = new Course();
		String result = A.checkStartTime(8) + A.checkEndTime(8);
		Assert.assertEquals(result, "1600 - 1700");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime9() {
		Course A = new Course();
		String result = A.checkStartTime(9) + A.checkEndTime(9);
		Assert.assertEquals(result, "1700 - 1800");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime10() {
		Course A = new Course();
		String result = A.checkStartTime(10) + A.checkEndTime(10);
		Assert.assertEquals(result, "1800 - 1900");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime11() {
		Course A = new Course();
		String result = A.checkStartTime(11) + A.checkEndTime(11);
		Assert.assertEquals(result, "1900 - 2000");
	}

	// Test checkTime() in Course()
	@Test
	public void test_checkTime12() {
		Course A = new Course();
		String result = A.checkStartTime(0) + A.checkEndTime(0);
		Assert.assertEquals(result, "ERROR - ERROR");
	}

	// Test test_checkTime in Course()
	@Test
	public void test_hashCode() {
		Course A = new Course();
		int result = A.hashCode();
		Assert.assertEquals(result, result);
	}

	// Test equal() in Course()
	@Test
	public void test_equal1() {
		Course j = new Course("CS3201", 3, 300, "mark");
		Course c = new Course("CS3201", 3, 300, "mark");
		boolean result = c.equals(j);
		Assert.assertEquals(result, true);
	}

	// Test equal() in Course()
	@Test
	public void test_equal2() {
		Course j = new Course("CS3201", 3, 300, "joe");
		Course c = new Course("CS3201", 3, 300, "mark");
		boolean result = c.equals(j);
		Assert.assertEquals(result, false);
	}

	// Test equal() in Course()
	@Test
	public void test_equal3() {
		Course j = new Course("CS3201", 3, 719, "mark");
		Course c = new Course("CS3201", 3, 300, "mark");
		boolean result = c.equals(j);
		Assert.assertEquals(result, false);
	}

	// Test equal() in Course()
	@Test
	public void test_equal4() {
		Course j = new Course("CS3201", 2, 300, "mark");
		Course c = new Course("CS3201", 3, 300, "mark");
		boolean result = c.equals(j);
		Assert.assertEquals(result, false);
	}

	// Test equal() in Course()
	@Test
	public void test_equal5() {
		Course j = new Course("GE2227", 3, 300, "mark");
		Course c = new Course("CS3201", 3, 300, "mark");
		boolean result = c.equals(j);
		Assert.assertEquals(result, false);
	}

	// Test equal() in Course()
	@Test
	public void test_equal6() {
		Course j = new Course("CS3201", 3, 300, "joe");
		ClassRoom m = new ClassRoom("4412", "AC2", 200, "Red");
		boolean result = j.equals(m);
		Assert.assertEquals(result, false);
	}

	@Test
	public void test_checkWeek1() {
		Course A = new Course();
		String result = A.checkWeek(1);
		Assert.assertEquals(result, "Mon");
	}

	@Test
	public void test_checkWeek2() {
		Course A = new Course();
		String result = A.checkWeek(2);
		Assert.assertEquals(result, "Tue");
	}

	@Test
	public void test_checkWeek3() {
		Course A = new Course();
		String result = A.checkWeek(3);
		Assert.assertEquals(result, "Wed");
	}

	@Test
	public void test_checkWeek4() {
		Course A = new Course();
		String result = A.checkWeek(4);
		Assert.assertEquals(result, "Thu");
	}

	@Test
	public void test_checkWeek5() {
		Course A = new Course();
		String result = A.checkWeek(5);
		Assert.assertEquals(result, "Fri");
	}

	@Test
	public void test_checkWeek6() {
		Course A = new Course();
		String result = A.checkWeek(0);
		Assert.assertEquals(result, "ERROR");
	}

	@Test
	public void test_setClass() {
		Course c = new Course();
		TimeTableColumn a = new TimeTableColumn();
		a.setClass(c);
	}

	@Test
	public void test_getCourse() {
		Course course;
		course = new Course("CS3343", 3, 200, "Tong Chan");
		TimeTableColumn timeTableColumn = new TimeTableColumn(course);
		Course c = timeTableColumn.getCourse();
		Assert.assertEquals(c, course);
	}
	
	@Test
	public void test_getInstructor() {
		Course course;
		course = new Course("CS3343", 3, 180, "Mary Wong");
		TimeTableColumn timeTableColumn = new TimeTableColumn(course);
		String instructor = timeTableColumn.getInstructor();
		Assert.assertEquals(instructor, "Mary Wong");
	}
	
	@Test
	public void test_set_count() {
		Course c = new Course();
		c.set_count(3);
		
	}
	@Test
	public void test_get_count() {
		Course c = new Course();
		c.set_count(3);
		Assert.assertEquals(c.get_count(), 3);
	}
	@Test
	public void set_ID() {
		Course c = new Course();
		c.set_ID("CS3343");
	}
	@Test
	public void get_ID() {
		Course c = new Course();
		c.set_ID("CS3343");
		Assert.assertEquals(c.get_ID(), "CS3343");
	}
	@Test
	public void test_getDuration() {
		Course course;
		course = new Course("CS3343", 3, 180, "Mary Wong");
		TimeTableColumn timeTableColumn = new TimeTableColumn(course);
		int duration = timeTableColumn.getDuration();
		Assert.assertEquals(duration, 3);
	}
	@Test
	public void setCount() {
		Course c = new Course();
		TimeTableColumn col = new TimeTableColumn(c);
		col.setCount(3);
	}
	@Test
	public void getCount() {
		Course c = new Course();
		TimeTableColumn col = new TimeTableColumn(c);
		col.setCount(3);
		Assert.assertEquals(col.getCount(), 3);
	}
	//-----------------------------------------
	/*
	 * check the isAvailable function in TimetableColumn() when there is a
	 * course in the timetable
	 */
	@Test
	public void testIsAvilable_course() {
		boolean result;
		TimeTableColumn col;
		Course c = new Course("CS3201", 3, 400, "mark");
		col = new TimeTableColumn(c);
		result = col.isAvailable();
		Assert.assertEquals(result, false);
	}

	/*
	 * check the isAvailable function in TimetableColumn() when there is no
	 * course in the timetable
	 */
	@Test
	public void testIsAvilable_null() {
		boolean result;
		TimeTableColumn col;
		Course c = null;
		col = new TimeTableColumn(c);
		result = col.isAvailable();
		Assert.assertEquals(result, true);
	}

	/*
	 * check the toString function in TimetableColumn()
	 */
	@Test
	public void testToString_TimeTableColumn() {
		String s;
		TimeTableColumn col;
		Course c = new Course("CS3201", 3, 400, "mark");
		col = new TimeTableColumn(c);
		boolean result = col.isAvailable();
		s = col.toString();
		Assert.assertEquals(s,
				"Course: CS3201	Room: null	ERROR	Duration : 3	ERROR - ERROR	mark");
	}

	//----------------------classroom-------------------
	@Test
	public void test_set_roomNumber(){
		ClassRoom rm = new ClassRoom();
		rm.set_roomNumber("4545");
	}
	@Test
	public void test_get_roomNumber(){
		ClassRoom rm = new ClassRoom();
		rm.set_roomNumber("4545");
		Assert.assertEquals(rm.get_roomNumber(), "4545");
	}
	@Test
	public void test_set_zone() {
		ClassRoom rm = new ClassRoom();
		rm.set_zone("Blue");
	}
	@Test
	public void test_get_zone() {
		ClassRoom rm = new ClassRoom();
		rm.set_zone("Blue");
		Assert.assertEquals(rm.get_zone(), "Blue");
	}
	@Test
	public void test_set_capacity(){
		ClassRoom rm = new ClassRoom();
		rm.set_capacity(200);
	}
	@Test
	public void get_capacity(){
		ClassRoom rm = new ClassRoom();
		rm.set_capacity(200);
		Assert.assertEquals(rm.get_capacity(), 200);
	}
	
	@Test
	public void test_set_building(){
		ClassRoom rm = new ClassRoom();
		rm.set_building("AC2");
	}
	@Test
	public void test_get_building(){
		ClassRoom rm = new ClassRoom();
		rm.set_building("AC2");
		Assert.assertEquals(rm.get_building(), "AC2");
	}
}
